package com.qf.film.view.service.impl;

import com.qf.film.view.dao.IFilmDao;
import com.qf.film.view.pojo.FilmInfo;
import com.qf.film.view.pojo.FilmType;
import com.qf.film.view.service.IFilmService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author King_long
 * @program: 20191025
 * @Date 2019-10-25 15:48
 */
@Service
public class FilmService implements IFilmService {
    private static final Logger LOGGER= LogManager.getLogger(FilmService.class);
    @Autowired
    private IFilmDao filmDao;

    @Override
    @Transactional
    public boolean insert(FilmInfo filmInfo) {
        int result = filmDao.insert(filmInfo);
        LOGGER.info("=================="+result);
        if (result == 1){
            return true;
        }else {
            return false;
        }

    }

    @Override
    @Transactional
    public boolean update(FilmInfo filmInfo) {
        int result = filmDao.update(filmInfo);
        LOGGER.info("=================="+result);
        if (result == 1){
            return true;
        }else {
            return false;
        }
    }

    @Override
    @Transactional
    public boolean delete(int filmId) {
        int result = filmDao.delete(filmId);
        LOGGER.info("=================="+result);
        if (result == 1){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<FilmInfo> search(Map<String,Object> map) {
        LOGGER.info("=================="+filmDao.search(map));
        return filmDao.search(map);
    }


    @Override
    public List<FilmType> selectType() {
        LOGGER.info("=================="+filmDao.selectType());
        return filmDao.selectType();
    }
}
